package com.ruoyi.project.er.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.er.domain.PaeaErType;
import com.ruoyi.project.er.mapper.PaeaErTypeMapper;
import com.ruoyi.project.er.service.IPaeaErTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 差错类型参数Service业务层处理
 *
 * @author ruoyi
 * @date 2020-03-14
 */
@Service
public class PaeaErTypeServiceImpl extends ServiceImpl<PaeaErTypeMapper, PaeaErType> implements IPaeaErTypeService
{
    @Resource
    private PaeaErTypeMapper paeaErTypeMapper;

    /**
     * 查询差错类型参数
     *
     * @param id 差错类型参数ID
     * @return 差错类型参数
     */
    @Override
    public PaeaErType selectPaeaErTypeById(String id)
    {
        return paeaErTypeMapper.selectPaeaErTypeById(id);
    }

    /**
     * 查询差错类型参数列表
     *
     * @param paeaErType 差错类型参数
     * @return 差错类型参数
     */
    @Override
    public List<PaeaErType> selectPaeaErTypeList(PaeaErType paeaErType)
    {
        return paeaErTypeMapper.selectPaeaErTypeList(paeaErType);
    }

    /**
     * 新增差错类型参数
     *
     * @param paeaErType 差错类型参数
     * @return 结果
     */
    @Override
    public int insertPaeaErType(PaeaErType paeaErType)
    {
        return paeaErTypeMapper.insertPaeaErType(paeaErType);
    }

    /**
     * 修改差错类型参数
     *
     * @param paeaErType 差错类型参数
     * @return 结果
     */
    @Override
    public int updatePaeaErType(PaeaErType paeaErType)
    {
        return paeaErTypeMapper.updatePaeaErType(paeaErType);
    }

    /**
     * 删除差错类型参数对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deletePaeaErTypeByIds(String ids)
    {
        return paeaErTypeMapper.deletePaeaErTypeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除差错类型参数信息
     *
     * @param id 差错类型参数ID
     * @return 结果
     */
    @Override
    public int deletePaeaErTypeById(String id)
    {
        return paeaErTypeMapper.deletePaeaErTypeById(id);
    }

    @Override
    public List<PaeaErType> selectPaeaErTypeAll() {
        return SpringUtils.getAopProxy(this).selectPaeaErTypeList(new PaeaErType());
    }

    @Override
    public List<PaeaErType> selectTypeById(String id) {
        PaeaErType paeaErType = paeaErTypeMapper.selectPaeaErTypeById(id);
        List<PaeaErType> types = paeaErTypeMapper.selectPaeaErTypeList(new PaeaErType());
        for (PaeaErType type : types)

            if (type.getId().equals(paeaErType.getId()))
            {
                type.setFlag(true);
                break;
            }
        return types;
    }
}
